/**
 * 
 */
package lt.vin.exaatto.server;

import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import lt.vin.exaatto.server.service.ChatService;

import com.google.appengine.api.xmpp.Message;
import com.google.appengine.api.xmpp.XMPPService;
import com.google.inject.Inject;
import com.google.inject.Singleton;

/**
 * @author Vincentas
 * 
 */
@Singleton
public class XMPPReceiverServlet extends HttpServlet {

	private static final long serialVersionUID = -9058527491520261291L;
	
	@Inject XMPPService xmpp;
	
	@Inject ChatService chatService;
	
	public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException {
		Message receivedMessage = xmpp.parseMessage(req);
		
		chatService.handle(receivedMessage);
	}
}
